package me.xue.communityhealth.repo;

import com.github.pagehelper.Page;
import me.xue.communityhealth.model.Fee;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface FeeRepository {

    @Insert("INSERT INTO `fee`(name,cost) VALUES(#{name},#{cost})")
    int save(Fee fee);

    @Update("UPDATE `fee` SET `name`=#{name},`cost`=#{cost} WHERE `id`=#{id}")
    int update(Fee fee);

    @Delete("DELETE FROM `fee` WHERE `id`=#{id}")
    int delete(int id);

    @Select("SELECT * FROM `fee` WHERE `name` LIKE #{name}")
    List<Fee> findByName(String name);

    @Select("SELECT * FROM `fee` WHERE `id`=#{id}")
    Fee findOne(int id);

    @Select("SELECT * FROM `fee`")
    Page<Fee> pagedFees();
}
